//=============================================================================

#ifndef ASURFACE_H
  #define ASURFACE_H

//=============================================================================

#include <windows.h>
#include "aVector.h"
#include "aSkin.h"

//=============================================================================

enum aseRet
{
  SURF_DONE = -128,
  SURF_NULLED_FILE_PATH,
  SURF_COL_BAD_DATA_VOLUME,
  SURF_COL_BAD_DATA_POINTER,
  SURF_COL_NO_VERTEXES_DATA,
  SURF_COL_NO_UV_DATA,
  SURF_COL_NO_NORMALS_DATA,
  SURF_ABS_BAD_DATA_POINTER,
  SURF_ABS_BAD_VERTEXES_COUNT,
};

//=============================================================================

class aSurface
{
  public:
    inline unsigned long asGetVertexesCount()const                              {return vertexesCount;}
    inline aVector asGetBBDiff()const                                           {return bbDiff;}
    inline void asRemoveSkinData()                                              {skin.asRemoveSkinData();}
    inline size_t asGetSurfaceDataVolume()const                                 {return size_t(vertexesCount*8*sizeof(float));}
    inline size_t asGetSkinDataVolume()const                                    {return skin.asGetDataVolume();}
    inline askRet asCollectSkinData(void* data, size_t wholeSize)const          {return skin.asCollectData(data, wholeSize);}
    inline int asGetMaterialTexturesCount()const                                {return skin.asGetTexturesCount();}
    inline askRet asAbsorbSkinData(char* data, int tCount)                      {return skin.asAbsorbData(data, tCount);}

    aSurface();
      virtual void asDrawSurface()const;
      bool asIsNULL()const;
      void asTranslateA(const aVector& vec);
      void asScaleA(const aVector& vec);
      aseRet asLoadSkin(const aString& path);
      virtual void asSpawnMemory(unsigned int tCount);
      virtual void asGenerateNormals();
      virtual void asRemoveSurfaceData();
      aseRet asCollectSurfaceData(void* vuvn, size_t wholeSize)const;
      aseRet asAbsorbSurfaceData(char* data, int vCount);
    virtual ~aSurface();
  
  protected:
    void asGetBB();
  
  private:
    virtual void asDrawNormals()const;

  public:
    aVector bbDiff;
    unsigned char color[3];
    bool draw;
    bool drawLines;
    bool drawTriangles;
    bool drawPoints;
    bool drawBB;
    bool drawNormals;
    bool drawOrigin;

  protected:
    float* vertexes;
    float* uv;
    float* normals;
    unsigned long vertexesCount;
    unsigned int trianglesCount;
    aVector rotation;
    const float bbOffset;
    float bb[108];
    aVector bbMin;
    aVector bbMax;
    aSkin skin;
    aVector origin;
};

//=============================================================================

#endif

//=============================================================================
